<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然金融中心管理平台</title>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <#include "/common/csslib.html">
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <div class="row h-home-path">
          <div class="col-md-12">
            <ol class="breadcrumb">
              <li><i class="fa fa-home"></i>&nbsp;&nbsp;所在位置</li>
              <li>首页</li>
              <li class="active">编辑表字段信息</li>
            </ol>
          </div>
        </div>
        <div class="row h-main-search">
          <form action="javascript:;" method="post">
            <div class="pull-right h-btn-group">
              <button class="btn btn-info" id="return-btn" onclick="SystemColumnInfoMgr.returnIndex()"><i
                      class="fa fa-mail-reply">&nbsp;&nbsp;</i>返回
              </button>
              <button class="btn btn-info" id="save" onclick="SystemColumnInfoMgr.submitForm()" type="button"><i
                      class="fa fa-save">&nbsp;&nbsp;</i>保存
              </button>
            </div>
          </form>
        </div>

        <div class="form-horizontal  h-form-warp">
          <div class="h-msg-title h-table-header">
            <strong>表字段信息</strong>
          </div>
          <form action="/systemColumnInfo/saveSystemColumnInfo" class="form-horizontal" id="systemColumnInfoForm"
                method="post" role="form">
            <input id="operation" name="operation" type="hidden" value="${operation!}"/>
            <input id="id" name="id" type="hidden" value="${systemColumnInfo.id!}"/>
            <input id="tableId" name="tableId" type="hidden" value="${systemTableInfo.id!}"/>
            <div class="form-group">
              <label class="col-sm-2 control-label">表名称：</label>
              <div class="col-sm-7">
                <input class="form-control" id="tableName" name="tableName" readonly="readonly"
                       required="required" type="text" value="${systemTableInfo.tableName!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">实体类字段编码：</label>
              <div class="col-sm-2">
                <input class="form-control" id="columnCode" name="columnCode" required="required"
                       type="text" value="${systemColumnInfo.columnCode!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
              <label class="col-sm-2 control-label">实体类字段名称：</label>
              <div class="col-sm-2">
                <input class="form-control" id="columnName" name="columnName" required="required"
                       type="text" value="${systemColumnInfo.columnName!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <@PageDict dict_name="columnType" dict_desc="实体类字段类型" dict_key="std_data_java_type"
              dict_value="${systemColumnInfo.columnType!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" />
              <label class="col-sm-2 control-label">数据库字段编码：</label>
              <div class="col-sm-2">
                <input class="form-control" id="columnSqlCode" name="columnSqlCode" required="required"
                       type="text" value="${systemColumnInfo.columnSqlCode!}"/>
              </div>
              <div class="col-sm-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <@PageDict dict_name="columnSqlType" dict_desc="数据库字段类型" dict_key="std_mysql_data_type"
              dict_value="${systemColumnInfo.columnSqlType!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" />
              <@PageDict dict_name="isPk" dict_desc="是否主键" dict_key="std_zb_yn" dict_value="${systemColumnInfo.isPk!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" default_value="N"/>
            </div>
            <div class="form-group">
              <@PageDict dict_name="isDict" dict_desc="是否数据字典" dict_key="std_zb_yn"
              dict_value="${systemColumnInfo.isDict!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" default_value="N" dict_method="SystemColumnInfoMgr.controlDict()"/>
              <div id="dictArea" style="display:none">
                <label class="col-sm-2 control-label">数据字典编码：</label>
                <div class="col-sm-2">
                  <input class="form-control" id="dictCode" name="dictCode" onblur="SystemColumnInfoMgr.checkDictCode()"
                         type="text" value="${systemColumnInfo.dictCode!}"/>
                </div>
              </div>
            </div>
            <div class="form-group">
              <@PageDict dict_name="isAmt" dict_desc="是否金额类型" dict_key="std_zb_yn"
              dict_value="${systemColumnInfo.isAmt!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" default_value="N"/>
              <@PageDict dict_name="isRate" dict_desc="是否利率类型" dict_key="std_zb_yn"
              dict_value="${systemColumnInfo.isRate!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" default_value="N"/>
            </div>
            <div class="form-group">
              <@PageDict dict_name="isNumber" dict_desc="是否数字类型" dict_key="std_zb_yn"
              dict_value="${systemColumnInfo.isNumber!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" default_value="N"/>
              <@PageDict dict_name="isDate" dict_desc="是否日期类型" dict_key="std_zb_yn"
              dict_value="${systemColumnInfo.isDate!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" default_value="N"/>
            </div>
            <div class="form-group">
              <@PageDict dict_name="isStrDate" dict_desc="是否字符串日期类型" dict_key="std_zb_yn"
              dict_value="${systemColumnInfo.isStrDate!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" default_value="N"/>
              <@PageDict dict_name="isRequired" dict_desc="是否必填类型" dict_key="std_zb_yn"
              dict_value="${systemColumnInfo.isRequired!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" default_value="Y"/>
            </div>
            <div class="form-group">
              <@PageDict dict_name="isListColumn" dict_desc="是否列表字段" dict_key="std_zb_yn"
              dict_value="${systemColumnInfo.isListColumn!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" default_value="Y"/>
              <@PageDict dict_name="isFormColumn" dict_desc="是否form表单字段" dict_key="std_zb_yn"
              dict_value="${systemColumnInfo.isFormColumn!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" default_value="Y"/>
            </div>
            <div class="form-group">
              <@PageDict dict_name="isOrderColumn" dict_desc="是否排序字段" dict_key="std_zb_yn"
              dict_value="${systemColumnInfo.isOrderColumn!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" default_value="N" dict_method="SystemColumnInfoMgr.controlOrder()"/>
              <div id="orderArea" style="display:none">
                <@PageDict dict_name="orderType" dict_desc="排序方式" dict_key="order_type"
                dict_value="${systemColumnInfo.orderType!}"
                dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
                required="required" default_value="asc"/>
              </div>
            </div>
            <div class="form-group">
              <@PageDict dict_name="isQueryColumn" dict_desc="是否查询字段" dict_key="std_zb_yn"
              dict_value="${systemColumnInfo.isQueryColumn!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" default_value="N" dict_method="SystemColumnInfoMgr.controlQuery()"/>
              <div id="queryArea" style="display:none">
                <@PageDict dict_name="queryType" dict_desc="查询方式" dict_key="query_type"
                dict_value="${systemColumnInfo.queryType!}"
                dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
                required="required" default_value="02"/>
              </div>
            </div>
            <div class="form-group">
              <@PageDict dict_name="isTextarea" dict_desc="是否长文本框" dict_key="std_zb_yn"
              dict_value="${systemColumnInfo.isTextarea!}"
              dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
              required="required" default_value="N"/>
              <div id="dictTypeArea" style="display:none">
                <@PageDict dict_name="dictType" dict_desc="数据字典类型" dict_key="std_dict_type"
                dict_value="${systemColumnInfo.dictType!}"
                dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-2"
                required="required" default_value="select"/>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">备注：</label>
              <div class="col-sm-7">
                <textarea class="col-sm-12" cols="" id="columnComment" name="columnComment" rows="280"
                          style="height:80px">${systemColumnInfo.columnComment!}</textarea>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
    <!-- end: PAGE -->
  </div>
  <!-- end: MAIN CONTAINER -->
</div>
<#include "/common/jslib.html">
<!-- form页面js -->
<script type="text/javascript">
    $(function () {
        // 页面操作类型：add(添加)-edit(编辑)-view(查看)
        var operation = $("#operation").val();
        SystemColumnInfoMgr = {
            // 初始化
            init: function () {
                // 查看的时候不显示保存按钮
                if (operation == "view") {
                    Jmts.setFormReadOnly();
                    $("#save").hide();
                }
                var isDict = "${systemColumnInfo.isDict!}";
                if (isDict == 'Y') {
                    $("#dictArea").show();
                    $("#dictTypeArea").show();
                }
                var isOrderColumn = "${systemColumnInfo.isOrderColumn!}";
                if (isOrderColumn == 'Y') {
                    $("#orderArea").show();
                }
                var isQueryColumn = "${systemColumnInfo.isQueryColumn!}";
                if (isQueryColumn == 'Y') {
                    $("#queryArea").show();
                }
            },
            // init end

            // 提交数据
            submitForm: function () {
                var isDict = $("#isDict").val();
                var dictCode = $("#dictCode").val();
                var isQueryColumn = $("#isQueryColumn").val();
                var queryType = $("#queryType").val();
                var isOrderColumn = $("#isOrderColumn").val();
                var orderType = $("#orderType").val();
                if (isDict == 'Y') {
                    if (dictCode == null || dictCode == '') {
                        Jmts.alert("数据字典编码不能为空");
                        $("#dictCode").focus();
                        return false;
                    }
                } else {
                    $("#dictCode").val('');
                }
                if (isQueryColumn == 'Y') {
                    if (queryType == null || queryType == '') {
                        Jmts.alert("查询方式不能为空");
                        $("#queryType").focus();
                        return false;
                    }
                } else {
                    $("#queryType").val('');
                }
                if (isOrderColumn == 'Y') {
                    if (orderType == null || orderType == '') {
                        Jmts.alert("排序方式不能为空");
                        $("#orderType").focus();
                        return false;
                    }
                } else {
                    $("#orderType").val('');
                }
                Jmts.ajaxSubmit(document.getElementById("systemColumnInfoForm"), function (result) {
                    var operation = result.operation;
                    if (result.success) {
                        Jmts.succTips(result.msg);
                        if (operation == 'add') {
                            SystemColumnInfoMgr.returnIndex();
                        } else if (operation == 'edit') {
                            window.location.reload();
                        }
                    } else {
                        Jmts.errorTips(result.msg);
                    }
                });
                return false;
            },
            // submitForm end
            //返回
            returnIndex: function () {
                var tableId = $("#tableId").val();
                window.location.href = "/systemColumnInfo/query?tableId=" + tableId + "&moduleId=${moduleId!}";
            },
            controlDict: function () {
                var isDict = $("#isDict").val();
                if (isDict == 'Y') {
                    $("#dictArea").show();
                    $("#dictTypeArea").show();
                } else {
                    $("#dictArea").hide();
                    $("#dictCode").val('');
                    $("#dictTypeArea").hide();
                    $("#dictType").val('');
                }
            },
            controlQuery: function () {
                var isQueryColumn = $("#isQueryColumn").val();
                if (isQueryColumn == 'Y') {
                    $("#queryArea").show();
                } else {
                    $("#queryArea").hide();
                    $("#queryType").val('');
                }
            },
            controlOrder: function () {
                var isOrderColumn = $("#isOrderColumn").val();
                if (isOrderColumn == 'Y') {
                    $("#orderArea").show();
                } else {
                    $("#orderArea").hide();
                    $("#orderType").val('');
                }
            },
            //检验数据字典编码是否存在字典表中
            checkDictCode: function () {
                var dictCode = $("#dictCode").val();
                if (dictCode == null || dictCode == '' || dictCode == 'undefined') {
                    return false;
                }
                var url = "/systemDict/checkDictCode";
                var data = {
                    dictCode: dictCode
                }
                Jmts.ajaxPost(url, data, function (result) {
                    if (result.success) {
                        if (!result.resultData.isExist) {
                            Jmts.alert(result.msg);
                            $("#dictCode").val('');
                        }
                    } else {
                        Jmts.warnTips(result.msg);
                        $("#dictCode").val('');
                    }
                });
            }
        };
        // 执行初始化
        SystemColumnInfoMgr.init();
        // 前台验证表单
        $("#systemColumnInfoForm").validate();
    });
</script>
</body>
</html>
